package com.xgc.book.bookserver.controller;


import com.xgc.book.bookserver.bean.NoticeBean;
import com.xgc.book.bookserver.service.NoticeService;
import com.xgc.book.bookserver.util.ResultJson;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 系统公告表 前端控制器
 * </p>
 *
 * @author wrz
 * @since 2023-11-20
 */
@RestController
@RequestMapping("/notice")
public class NoticeController {
    @Autowired
    private NoticeService noticeService;

    @GetMapping("/page")
    public ResultJson getPage(int page, int limit, NoticeBean noticeBean) {
        return noticeService.getPage(page, limit, noticeBean);
    }

    @GetMapping("/info/{id}")
    public ResultJson getById(@PathVariable Integer id) {
        return ResultJson.ok(noticeService.getById(id));
    }

    @PostMapping(value = {"/update", "/status"})
    public ResultJson update(@RequestBody NoticeBean noticeBean) {
        noticeService.saveOrUpdate(noticeBean);
        return ResultJson.ok();
    }

    @DeleteMapping("/delete/{id}")
    public ResultJson delete(@PathVariable Integer id) {
        noticeService.removeById(id);
        return ResultJson.ok();
    }
}

